package com.intelligent.ispc.client.utils.chart;

/**
 * Created by Can.Guan on 2016/7/13.
 */
public class RangeUtils {
    private double[] data;
    private double upperBound;
    private double lowerBound;

    public RangeUtils(double[] data) {
        this.data = data;
        this.getBound();
    }

    private void getBound() {
        double min = data[0];
        double max = data[0];
        for (int i = 0; i < data.length; i++) {
            if (max < data[i]) {
                max = data[i];
            }
            if (min > data[i]) {
                min = data[i];
            }
        }
        this.upperBound = max;
        this.lowerBound = min;
    }

    public void setData(double[] data) {
        this.data = data;
        this.getBound();
    }

    public double[] getData() {
        return data;
    }

    public double getUpperBound() {
        return upperBound;
    }

    public double getLowerBound() {
        return lowerBound;
    }
}
